﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace ARR.UI.Views
{
    /// <summary>
    /// Interaction logic for CategoryMatchView.xaml
    /// </summary>
    public partial class CategoryMatchView : Window
    {
        public CategoryMatchView()
        {
            InitializeComponent();
        }

        private void CategoriesRadTreeView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (this.CategoriesRadTreeView.SelectedItem != null)
            {
                if (((Entities.Category)this.CategoriesRadTreeView.SelectedItem).Level == 2)
                {
                    MessageBox.Show("Los SKUs sólo pueden ser asociados a una subcategoría");
                }
                else
                {
                    ((ARR.UI.ViewModels.CategoryMatchViewModel)this.DataContext).Match.CategoryId = ((Entities.Category)this.CategoriesRadTreeView.SelectedItem).Id;
                    CategoriesRadTreeViewButton.Content = ((Entities.Category)this.CategoriesRadTreeView.SelectedItem).Name;
                    CategoriesRadTreeViewButton.IsOpen = false;
                }
            }
        }
    }
}
